package com.kexun.dao.impl;

import com.kexun.pojo.User;
import com.kexun.dao.PublicDao;
import com.kexun.util.DruidUtil;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

public class PublicDaoImpl implements PublicDao {
    //获取数据源
    private JdbcTemplate  t = new JdbcTemplate(DruidUtil.getDataSource());




    @Override
    public User login(String num) {

        String sql = "select * from user where user_num =?";
        User user = null;
        try {
            user = t.queryForObject(sql, new BeanPropertyRowMapper<>(User.class), num);
        } catch (DataAccessException e) {
            return null;
        }

        return user;
    }



}
